{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "43497beb-817d-4366-9156-f4d7f0d44942",
      "metadata": {
        "id": "43497beb-817d-4366-9156-f4d7f0d44942"
      },
      "source": [
        "# Customer Support RAG Agent\n",
        "\n",
        "In this guide, you build an **agent** to perform **RAG** and answer questions related to a car manual PDF using [LlamaIndex](https://github.com/run-llama/llama_index), [Redis](https://redis.io), and [Cohere](https://cohere.com/).\n",
        "\n",
        "![image.png]()"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "77ac7184",
      "metadata": {
        "id": "77ac7184"
      },
      "source": [
        "If you're opening this Notebook on colab, you will need to install LlamaIndex 🦙 and a number of related integration dependencies."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "4eff88ab",
      "metadata": {
        "id": "4eff88ab",
        "collapsed": true
      },
      "outputs": [],
      "source": [
        "# @title\n",
        "%pip install -U llama-index llama-parse llama-hub\n",
        "%pip install llama-index-vector-stores-redis\n",
        "%pip install llama-index-storage-docstore-redis\n",
        "%pip install llama-index-storage-chat-store-redis\n",
        "%pip install llama-index-llms-cohere\n",
        "%pip install llama-index-embeddings-cohere\n",
        "%pip install llama-index-embeddings-huggingface"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "1f0e47ac-ec6d-48eb-93a3-0e1fcab22112",
      "metadata": {
        "id": "1f0e47ac-ec6d-48eb-93a3-0e1fcab22112"
      },
      "outputs": [],
      "source": [
        "%load_ext autoreload\n",
        "%autoreload 2"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "9be00aba-b6c5-4940-9825-81c5d2cd2f0b",
      "metadata": {
        "id": "9be00aba-b6c5-4940-9825-81c5d2cd2f0b"
      },
      "source": [
        "## Setup and Download Data\n",
        "\n",
        "In this section, we'll set up a simple Redis db, configure the environment, and ingest the PDF document."
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Setup Redis"
      ],
      "metadata": {
        "id": "Po4K08Uoa5HJ"
      },
      "id": "Po4K08Uoa5HJ"
    },
    {
      "cell_type": "code",
      "source": [
        "%%sh\n",
        "curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg\n",
        "echo \"deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/redis.list\n",
        "sudo apt-get update  > /dev/null 2>&1\n",
        "sudo apt-get install redis-stack-server  > /dev/null 2>&1\n",
        "redis-stack-server --daemonize yes"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VLy0onoAa7KI",
        "outputId": "1a70473d-dd1c-4160-97ad-c7f0b051786d"
      },
      "id": "VLy0onoAa7KI",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb jammy main\n",
            "Starting redis-stack-server, database path /var/lib/redis-stack\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "REDIS_HOST=\"localhost\"\n",
        "REDIS_PORT=6379\n",
        "REDIS_PASSWORD=\"\""
      ],
      "metadata": {
        "id": "7c2KKPhOh4zM"
      },
      "id": "7c2KKPhOh4zM",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Environment Configuration\n",
        "You will need both a LlamaCloud API Key and a Cohere API Key."
      ],
      "metadata": {
        "id": "DTusYzlJa876"
      },
      "id": "DTusYzlJa876"
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "\n",
        "os.environ[\"LLAMA_CLOUD_API_KEY\"] = \"YOUR API KEY\"\n",
        "os.environ[\"CO_API_KEY\"] = \"YOUR API KEY\""
      ],
      "metadata": {
        "id": "TjHWvyTtXNiK"
      },
      "id": "TjHWvyTtXNiK",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# need this for running llama-index code in Jupyter Notebooks\n",
        "import nest_asyncio\n",
        "nest_asyncio.apply()"
      ],
      "metadata": {
        "id": "b4CGkFIhX86t"
      },
      "id": "b4CGkFIhX86t",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Download, Parse and Ingest Document\n",
        "First we will download the PDF for this example. We will use a simple bash command to pull the file from a related github project."
      ],
      "metadata": {
        "id": "CEIZjXY9mL6m"
      },
      "id": "CEIZjXY9mL6m"
    },
    {
      "cell_type": "code",
      "source": [
        "!mkdir -p 'data/'\n",
        "!wget 'https://raw.githubusercontent.com/redis-developer/LLM-Document-Chat/main/docs/2022-chevrolet-colorado-ebrochure.pdf' -O 'data/2022-chevrolet-colorado-ebrochure.pdf'"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "2WsfdF550FYc",
        "outputId": "f571e158-0b7e-481b-99f5-048611590dde"
      },
      "id": "2WsfdF550FYc",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "--2024-04-16 02:26:52--  https://raw.githubusercontent.com/redis-developer/LLM-Document-Chat/main/docs/2022-chevrolet-colorado-ebrochure.pdf\n",
            "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n",
            "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.\n",
            "HTTP request sent, awaiting response... 200 OK\n",
            "Length: 3566101 (3.4M) [application/octet-stream]\n",
            "Saving to: ‘data/2022-chevrolet-colorado-ebrochure.pdf’\n",
            "\n",
            "data/2022-chevrolet 100%[===================>]   3.40M  --.-KB/s    in 0.07s   \n",
            "\n",
            "2024-04-16 02:26:53 (46.1 MB/s) - ‘data/2022-chevrolet-colorado-ebrochure.pdf’ saved [3566101/3566101]\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Using LlamaParse on LlamaCloud, parsing the PDF is done with great precision and accuracy."
      ],
      "metadata": {
        "id": "O4B9M1Yiz4v7"
      },
      "id": "O4B9M1Yiz4v7"
    },
    {
      "cell_type": "code",
      "source": [
        "from llama_parse import LlamaParse\n",
        "from llama_index.core import SimpleDirectoryReader\n",
        "\n",
        "parser = LlamaParse(\n",
        "    result_type=\"markdown\"  # \"markdown\" and \"text\" are available\n",
        ")\n",
        "\n",
        "file_extractor = {\".pdf\": parser}\n",
        "reader = SimpleDirectoryReader(\"./data\", file_extractor=file_extractor)\n",
        "documents = reader.load_data()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "iHhaz-ezW0dy",
        "outputId": "ea57646c-dda7-4e56-ff7d-d9e1b320cdea"
      },
      "id": "iHhaz-ezW0dy",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Started parsing the file under job_id 2c35fd53-fce2-4a41-b2b7-a7a064f6d350\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Below we build a custom index schema for the `RedisVectorStore` that uses the cohere embedding model and some custom index specifications."
      ],
      "metadata": {
        "id": "Jms33LO5t_6c"
      },
      "id": "Jms33LO5t_6c"
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "c9c3c2a9-c546-410d-9fbd-1a76f8da4ecc",
      "metadata": {
        "id": "c9c3c2a9-c546-410d-9fbd-1a76f8da4ecc"
      },
      "outputs": [],
      "source": [
        "from llama_index.embeddings.cohere import CohereEmbedding\n",
        "from llama_index.core.ingestion import (\n",
        "    DocstoreStrategy,\n",
        "    IngestionPipeline,\n",
        "    IngestionCache,\n",
        ")\n",
        "from llama_index.storage.kvstore.redis import RedisKVStore as RedisCache\n",
        "from llama_index.storage.docstore.redis import RedisDocumentStore\n",
        "from llama_index.core.node_parser import SentenceSplitter\n",
        "from llama_index.vector_stores.redis import RedisVectorStore\n",
        "\n",
        "from redisvl.schema import IndexSchema\n",
        "\n",
        "\n",
        "embed_model = CohereEmbedding(input_type=\"search_document\")\n",
        "\n",
        "custom_schema = IndexSchema.from_dict(\n",
        "    {\n",
        "        \"index\": {\n",
        "            \"name\": \"chevy-colorado\",\n",
        "            \"prefix\": \"pdf:chunk\",\n",
        "            \"key_separator\": \":\"\n",
        "          },\n",
        "        # customize fields that are indexed\n",
        "        \"fields\": [\n",
        "            # required fields for llamaindex\n",
        "            {\"type\": \"tag\", \"name\": \"id\"},\n",
        "            {\"type\": \"tag\", \"name\": \"doc_id\"},\n",
        "            {\"type\": \"text\", \"name\": \"text\"},\n",
        "            # custom vector field for cohere embeddings\n",
        "            {\n",
        "                \"type\": \"vector\",\n",
        "                \"name\": \"vector\",\n",
        "                \"attrs\": {\n",
        "                    \"dims\": 1024,\n",
        "                    \"algorithm\": \"hnsw\",\n",
        "                    \"distance_metric\": \"cosine\",\n",
        "                },\n",
        "            },\n",
        "        ],\n",
        "    }\n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "Now we can build an end to end ingestion pipeline as a sequence of transformations backed by a cache, document store, and a sink. **Notice that Redis is used at all stages of the ingest pipeline to process documents at scale, minimizing redundant compute (and thus long-running costs).**\n",
        "\n",
        "![image.png]()"
      ],
      "metadata": {
        "id": "j9expyHYuSN3"
      },
      "id": "j9expyHYuSN3"
    },
    {
      "cell_type": "code",
      "source": [
        "vector_index_pipeline = IngestionPipeline(\n",
        "    transformations=[\n",
        "        SentenceSplitter(),\n",
        "        embed_model,\n",
        "    ],\n",
        "    docstore=RedisDocumentStore.from_host_and_port(\n",
        "        REDIS_HOST, REDIS_PORT, namespace=\"doc-store\"\n",
        "    ),\n",
        "    vector_store=RedisVectorStore(\n",
        "        schema=custom_schema,\n",
        "        redis_url=f\"redis://{REDIS_HOST}:{REDIS_PORT}\",\n",
        "    ),\n",
        "    cache=IngestionCache(\n",
        "        cache=RedisCache.from_host_and_port(REDIS_HOST, REDIS_PORT),\n",
        "        collection=\"doc-cache\",\n",
        "    ),\n",
        "    docstore_strategy=DocstoreStrategy.UPSERTS,\n",
        ")"
      ],
      "metadata": {
        "id": "0QLBztgmZXlD"
      },
      "id": "0QLBztgmZXlD",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "vector_index_pipeline.run(documents=documents, show_progress=True)"
      ],
      "metadata": {
        "id": "AtPIqKFram-f"
      },
      "id": "AtPIqKFram-f",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Test pipeline consistency and optimizations\n",
        "Since we are using the document store and cache, we can run the exact same document through, and note that nothing else is ingested because it's already been done. **This helps prevent redundant computation on ETL, improving costs and throughput at scale.**\n"
      ],
      "metadata": {
        "id": "HefsmjnZaqDX"
      },
      "id": "HefsmjnZaqDX"
    },
    {
      "cell_type": "code",
      "source": [
        "vector_index_pipeline.run(documents=documents)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "9Xr1yVHqas5b",
        "outputId": "e39426ea-cb73-4899-d2d6-910d922668b2"
      },
      "id": "9Xr1yVHqas5b",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[]"
            ]
          },
          "metadata": {},
          "execution_count": 12
        }
      ]
    },
    {
      "cell_type": "markdown",
      "id": "976cd798-2e8d-474c-922a-51b12c5c6f36",
      "metadata": {
        "id": "976cd798-2e8d-474c-922a-51b12c5c6f36"
      },
      "source": [
        "## Building the ReAct Agent\n",
        "\n",
        "In this section we define a **ReAct** agent that will perform RAG over a PDF document using the Cohere `command-r-plus` language model.\n",
        "\n",
        "**ReAct** is an agent based on a query engine over your data. For each chat interaction, the agent enter a ReAct loop:\n",
        "\n",
        "- decide whether to use the query engine tool and come up with appropriate input\n",
        "- (optional) use the query engine tool and observe its output\n",
        "- decide whether to repeat or give final response\n",
        "\n",
        "### Agent Setup\n",
        "\n",
        "Below we define our LLM, embedding model, and a chat memory layer backed by Redis for conversation history and context.\n",
        "\n",
        "We define both a vector index (for semantic search) and summary index (for summarization) for the document -- used as tools by the agent."
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Setup Cohere as the base embedding model and LLM\n",
        "from llama_index.llms.cohere import Cohere\n",
        "from llama_index.core import Settings\n",
        "\n",
        "llm = Cohere(model=\"command-r-plus\")\n",
        "Settings.llm = llm\n",
        "Settings.embed_model = CohereEmbedding(input_type=\"search_query\")"
      ],
      "metadata": {
        "id": "dgczKV4mf_QP"
      },
      "id": "dgczKV4mf_QP",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Set up memory for the Agent\n",
        "from llama_index.storage.chat_store.redis import RedisChatStore\n",
        "from llama_index.core.memory import ChatMemoryBuffer\n",
        "\n",
        "# Build chat memory backed by Redis\n",
        "chat_memory = ChatMemoryBuffer.from_defaults(\n",
        "    token_limit=3000,\n",
        "    chat_store=RedisChatStore(redis_url=f\"redis://{REDIS_HOST}:{REDIS_PORT}\", ttl=300),\n",
        "    chat_store_key=\"user_1\"\n",
        ")"
      ],
      "metadata": {
        "id": "U8q6I7hgtbhS"
      },
      "id": "U8q6I7hgtbhS",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "eacdf3a7-cfe3-4c2b-9037-b28a065ed148",
      "metadata": {
        "id": "eacdf3a7-cfe3-4c2b-9037-b28a065ed148"
      },
      "outputs": [],
      "source": [
        "from llama_index.core.agent import ReActAgent\n",
        "from llama_index.core import SummaryIndex, VectorStoreIndex\n",
        "from llama_index.core.tools import QueryEngineTool, ToolMetadata\n",
        "from llama_index.core.node_parser import SentenceSplitter\n",
        "\n",
        "import pickle\n",
        "\n",
        "\n",
        "async def build_doc_agent(doc):\n",
        "    # ID will be base + parent\n",
        "    file_name = doc.metadata[\"file_name\"]\n",
        "    file_path = f\"./data/{file_name}\"\n",
        "    file_id = file_name.replace(\"-\", \"_\").strip(\".pdf\")\n",
        "    print(file_id)\n",
        "\n",
        "    # Run ingestion\n",
        "    vector_index_pipeline.run(documents=[doc], show_progress=True)\n",
        "\n",
        "    # Grab the nodes\n",
        "    node_parser = SentenceSplitter()\n",
        "    nodes = node_parser.get_nodes_from_documents([doc])\n",
        "\n",
        "    # Define vector index and query engine\n",
        "    vector_index = VectorStoreIndex.from_vector_store(\n",
        "        vector_index_pipeline.vector_store\n",
        "    )\n",
        "    vector_query_engine = vector_index.as_query_engine()\n",
        "\n",
        "    # Build summary index and extract a summary\n",
        "    summary_index = SummaryIndex(nodes)\n",
        "    summary_query_engine = summary_index.as_query_engine(\n",
        "        response_mode=\"tree_summarize\"\n",
        "    )\n",
        "    summary_out_path = f\"./data/{file_name}_summary.pkl\"\n",
        "    summary = str(\n",
        "        await summary_query_engine.aquery(\n",
        "            \"Extract a concise 1-2 line summary of this document\"\n",
        "        )\n",
        "    )\n",
        "    pickle.dump(summary, open(summary_out_path, \"wb\"))\n",
        "\n",
        "    # Define agent tools\n",
        "    query_engine_tools = [\n",
        "        QueryEngineTool(\n",
        "            query_engine=vector_query_engine,\n",
        "            metadata=ToolMetadata(\n",
        "                name=f\"vector_tool_{file_id}\",\n",
        "                description=f\"Useful for questions related to specific facts about the chevy colorado\",\n",
        "            ),\n",
        "        )\n",
        "    ]\n",
        "\n",
        "    # Build ReAct agent\n",
        "    agent = ReActAgent.from_tools(\n",
        "        query_engine_tools,\n",
        "        llm=llm,\n",
        "        verbose=True,\n",
        "        memory=chat_memory,\n",
        "        context=f\"\"\"\\\n",
        "You are a specialized, trustworthy, helpful, and technical customer support agent designed to answer queries about the Chevy Colorado 2022 vehicle.\n",
        "Use the available tools provided when answering a question. Do NOT just blindly make things up about the car unless it is grounded by the retrieved sources.\\\n",
        "\"\"\")\n",
        "\n",
        "    return agent, summary\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "44748b46-dd6b-4d4f-bc70-7022ae96413f",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "44748b46-dd6b-4d4f-bc70-7022ae96413f",
        "outputId": "30b6a71f-0c43-44c0-bafe-fc838c2e2001"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "2022_chevrolet_colorado_ebrochure\n",
            "02:28:47 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "02:28:47 llama_index.core.agent.react.formatter WARNING   ReActChatFormatter.from_context is deprecated, please use `from_defaults` instead.\n"
          ]
        }
      ],
      "source": [
        "agent, doc_summary = await build_doc_agent(documents[0])"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "doc_summary"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 53
        },
        "id": "BB12CBvJoSJv",
        "outputId": "51efa7a5-b7e4-4c86-a6b3-d0c2771d9011"
      },
      "id": "BB12CBvJoSJv",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'The 2022 Chevrolet Colorado is a midsize pickup truck with four models, three engine options, and various special editions and packages. It offers a range of features, including different cab and bed sizes, advanced technology, and off-road capabilities.'"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            }
          },
          "metadata": {},
          "execution_count": 17
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Using the Agent\n",
        "Below we will use our agent.\n",
        "\n",
        "![image.png]()\n",
        "\n"
      ],
      "metadata": {
        "id": "jXpe-_Vutikn"
      },
      "id": "jXpe-_Vutikn"
    },
    {
      "cell_type": "code",
      "source": [
        "response = agent.chat(\"What is the seating capacity of the vehicle?\")\n",
        "print(str(response))"
      ],
      "metadata": {
        "id": "buZkf9Q7ogMN",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "ed7e179d-0e61-4653-820d-a33ac82f604c"
      },
      "id": "buZkf9Q7ogMN",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:29:01 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: The current language of the user is: English. I need to use a tool to help me answer the question.\n",
            "Action: vector_tool_2022_chevrolet_colorado_ebrochure\n",
            "Action Input: {'input': 'How many people can fit in the car?'}\n",
            "\u001b[0m02:29:01 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/embed \"HTTP/1.1 200 OK\"\n",
            "02:29:01 llama_index.vector_stores.redis.base INFO   Querying index chevy-colorado with filters *\n",
            "02:29:01 llama_index.vector_stores.redis.base INFO   Found 2 results for query with id ['pdf:chunk:2f38b008-f1af-4123-ac14-e24e0cb70a47', 'pdf:chunk:1650d50b-5936-45b4-b1cd-9b855f377ef7']\n",
            "02:29:02 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;34mObservation: The text does not specify the seating capacity of the car.\n",
            "\u001b[0m02:29:04 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: I cannot answer the question with the provided tools.\n",
            "Answer: Sorry, I could not find the seating capacity of the 2022 Chevrolet Colorado in the provided sources.\n",
            "\u001b[0mSorry, I could not find the seating capacity of the 2022 Chevrolet Colorado in the provided sources.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "response = agent.chat(\"What is the towing capacity?\")\n",
        "print(str(response))"
      ],
      "metadata": {
        "id": "XlrRBScWp_Wy",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "2366de7a-c1cd-423b-fc85-58589c6cf014"
      },
      "id": "XlrRBScWp_Wy",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:29:07 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: The current language of the user is: English. I need to use a tool to help me answer the question.\n",
            "Action: vector_tool_2022_chevrolet_colorado_ebrochure\n",
            "Action Input: {'input': 'What is the towing capacity?'}\n",
            "\u001b[0m02:29:07 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/embed \"HTTP/1.1 200 OK\"\n",
            "02:29:07 llama_index.vector_stores.redis.base INFO   Querying index chevy-colorado with filters *\n",
            "02:29:07 llama_index.vector_stores.redis.base INFO   Found 2 results for query with id ['pdf:chunk:444bbb71-04fc-4547-a069-0cadee0ff9b3', 'pdf:chunk:1650d50b-5936-45b4-b1cd-9b855f377ef7']\n",
            "02:29:10 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;34mObservation: The 2022 Chevrolet Colorado has a maximum trailering/towing capacity of 7,700 lbs when equipped with the available Duramax 2.8L Turbo-Diesel engine. The towing capacity varies based on the configuration and engine choice. For example, the Crew Cab Short Box LT with 2WD and the available Trailering Package can tow up to 7,700 lbs, while the ZR2 model can tow up to 5,000 lbs.\n",
            "\u001b[0m02:29:15 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: I can answer without using any more tools. I'll use the user's language to answer\n",
            "Answer: The towing capacity of the 2022 Chevrolet Colorado varies depending on the configuration and engine choice. When equipped with the available Duramax 2.8L Turbo-Diesel engine, it can achieve a maximum trailering capacity of 7,700 lbs. For example, the Crew Cab Short Box LT with 2WD and the Trailering Package can also tow up to 7,700 lbs, whereas the ZR2 model has a towing capacity of 5,000 lbs.\n",
            "\u001b[0mThe towing capacity of the 2022 Chevrolet Colorado varies depending on the configuration and engine choice. When equipped with the available Duramax 2.8L Turbo-Diesel engine, it can achieve a maximum trailering capacity of 7,700 lbs. For example, the Crew Cab Short Box LT with 2WD and the Trailering Package can also tow up to 7,700 lbs, whereas the ZR2 model has a towing capacity of 5,000 lbs.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "response = agent.chat(\"Is there a trailer hitch on the back of the truck?\")\n",
        "print(str(response))"
      ],
      "metadata": {
        "id": "z9WBrCZbqJL9",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "1696168d-fc18-4c79-852b-d0cbdcf7729a"
      },
      "id": "z9WBrCZbqJL9",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:29:17 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: The current language of the user is: English. I need to use a tool to help me answer the question.\n",
            "Action: vector_tool_2022_chevrolet_colorado_ebrochure\n",
            "Action Input: {'input': 'trailer hitch'}\n",
            "\u001b[0m02:29:17 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/embed \"HTTP/1.1 200 OK\"\n",
            "02:29:17 llama_index.vector_stores.redis.base INFO   Querying index chevy-colorado with filters *\n",
            "02:29:17 llama_index.vector_stores.redis.base INFO   Found 2 results for query with id ['pdf:chunk:fcd08dab-f086-489c-bdab-e1ea5a3794a9', 'pdf:chunk:444bbb71-04fc-4547-a069-0cadee0ff9b3']\n",
            "02:29:19 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;34mObservation: The trailer hitch is included in the Trailering Package, which is standard on Crew Cab Long Box models. It is also available as an option on other configurations when combined with specific engine and rear differential configurations.\n",
            "\u001b[0m02:29:22 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: I can answer without using any more tools. I'll use the user's language to answer\n",
            "Answer: Yes, the 2022 Chevrolet Colorado can be equipped with a trailer hitch. It is included in the Trailering Package, which is standard on Crew Cab Long Box models. For other configurations, the trailer hitch is available as an option, depending on the engine and rear differential choices.\n",
            "\u001b[0mYes, the 2022 Chevrolet Colorado can be equipped with a trailer hitch. It is included in the Trailering Package, which is standard on Crew Cab Long Box models. For other configurations, the trailer hitch is available as an option, depending on the engine and rear differential choices.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "response = agent.chat(\"Tell me about the pros and cons of this truck.\")\n",
        "print(str(response))"
      ],
      "metadata": {
        "id": "dP4vNtnBqUIZ",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "bc0a0cec-776b-4425-dd46-757894391fed"
      },
      "id": "dP4vNtnBqUIZ",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:29:24 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: The current language of the user is: English. I need to use a tool to help me answer the question.\n",
            "Action: vector_tool_2022_chevrolet_colorado_ebrochure\n",
            "Action Input: {'input': 'pros and cons'}\n",
            "\u001b[0m02:29:24 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/embed \"HTTP/1.1 200 OK\"\n",
            "02:29:24 llama_index.vector_stores.redis.base INFO   Querying index chevy-colorado with filters *\n",
            "02:29:24 llama_index.vector_stores.redis.base INFO   Found 2 results for query with id ['pdf:chunk:66fa380a-865a-4e7a-a8be-8f54e55c25de', 'pdf:chunk:22cba2f7-df0b-4fcf-b275-a42d66daba7e']\n",
            "02:29:33 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;34mObservation: **Pros:**\n",
            "- The 2022 Chevrolet Colorado offers a range of features that enhance its functionality, performance, and comfort.\n",
            "- It has a variety of safety features, including dual-stage frontal airbags, side-impact airbags, head-curtain airbags, and a rear vision camera.\n",
            "- The vehicle also offers a choice between two transmission options: a 6-speed automatic and an 8-speed automatic, both electronically controlled with overdrive.\n",
            "- The Z71 model comes with a comprehensive Z71 Off-Road Suspension Package and mechanical features such as an automatic locking rear differential and a powerful 3.6L DOHC V6 engine.\n",
            "- The interior features entertainment options like the Chevrolet Infotainment 3 Plus system and convenient features such as remote vehicle start and power-adjustable seats.\n",
            "\n",
            "**Cons:**\n",
            "- Some features shown in the brochure may have limited availability or may not be available at all, which could impact the customer's desired configuration.\n",
            "- The use of recovery hooks for towing is not recommended due to safety concerns, which may limit the vehicle's towing capabilities for certain situations.\n",
            "- Certain features, such as the Lane Departure Warning and Forward Collision Alert, are only available on specific models or require additional packages to be purchased.\n",
            "- Extra costs are associated with certain color options and interior choices, which could increase the overall price of the vehicle.\n",
            "\u001b[0m02:29:40 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: I can answer without using any more tools. I'll use the user's language to answer.\n",
            "Answer: Here are some pros and cons to help you evaluate the 2022 Chevrolet Colorado: \n",
            "\n",
            "**Pros:**\n",
            "- The Colorado offers a range of features to enhance functionality, performance, and comfort.\n",
            "- It has an impressive list of standard safety features, including multiple airbags and a rear vision camera.\n",
            "- You can choose between two advanced transmission options: a 6-speed or 8-speed automatic, both with overdrive.\n",
            "- The Z71 model is an off-road-capable variant with a specialized suspension package and a powerful V6 engine.\n",
            "- Entertainment and convenience features, such as infotainment systems and remote start, add to the overall appeal.\n",
            "\n",
            "**Cons:**\n",
            "- Some features shown in promotional materials may not be available or could be limited in certain configurations.\n",
            "- Recovery hooks are not recommended for towing, which may restrict towing options.\n",
            "- Certain advanced driver-assistance systems (ADAS) features are only available on specific models or require additional packages.\n",
            "- There are extra costs associated with certain color and interior choices, which could increase the overall price.\n",
            "\u001b[0mHere are some pros and cons to help you evaluate the 2022 Chevrolet Colorado: \n",
            "\n",
            "**Pros:**\n",
            "- The Colorado offers a range of features to enhance functionality, performance, and comfort.\n",
            "- It has an impressive list of standard safety features, including multiple airbags and a rear vision camera.\n",
            "- You can choose between two advanced transmission options: a 6-speed or 8-speed automatic, both with overdrive.\n",
            "- The Z71 model is an off-road-capable variant with a specialized suspension package and a powerful V6 engine.\n",
            "- Entertainment and convenience features, such as infotainment systems and remote start, add to the overall appeal.\n",
            "\n",
            "**Cons:**\n",
            "- Some features shown in promotional materials may not be available or could be limited in certain configurations.\n",
            "- Recovery hooks are not recommended for towing, which may restrict towing options.\n",
            "- Certain advanced driver-assistance systems (ADAS) features are only available on specific models or require additional packages.\n",
            "- There are extra costs associated with certain color and interior choices, which could increase the overall price.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "agent.memory.chat_store.get_messages(\"user_1\")"
      ],
      "metadata": {
        "id": "kngLFj1m2x2y",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "f6a2d67d-72ce-4c27-9281-aaf2ea7d3d84"
      },
      "id": "kngLFj1m2x2y",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[ChatMessage(role=<MessageRole.USER: 'user'>, content='What is the seating capacity of the vehicle?', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='Sorry, I could not find the seating capacity of the 2022 Chevrolet Colorado in the provided sources.', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.USER: 'user'>, content='What is the towing capacity?', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='The towing capacity of the 2022 Chevrolet Colorado varies depending on the configuration and engine choice. When equipped with the available Duramax 2.8L Turbo-Diesel engine, it can achieve a maximum trailering capacity of 7,700 lbs. For example, the Crew Cab Short Box LT with 2WD and the Trailering Package can also tow up to 7,700 lbs, whereas the ZR2 model has a towing capacity of 5,000 lbs.', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.USER: 'user'>, content='Is there a trailer hitch on the back of the truck?', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='Yes, the 2022 Chevrolet Colorado can be equipped with a trailer hitch. It is included in the Trailering Package, which is standard on Crew Cab Long Box models. For other configurations, the trailer hitch is available as an option, depending on the engine and rear differential choices.', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.USER: 'user'>, content='Tell me about the pros and cons of this truck.', additional_kwargs={}),\n",
              " ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='Here are some pros and cons to help you evaluate the 2022 Chevrolet Colorado: \\n\\n**Pros:**\\n- The Colorado offers a range of features to enhance functionality, performance, and comfort.\\n- It has an impressive list of standard safety features, including multiple airbags and a rear vision camera.\\n- You can choose between two advanced transmission options: a 6-speed or 8-speed automatic, both with overdrive.\\n- The Z71 model is an off-road-capable variant with a specialized suspension package and a powerful V6 engine.\\n- Entertainment and convenience features, such as infotainment systems and remote start, add to the overall appeal.\\n\\n**Cons:**\\n- Some features shown in promotional materials may not be available or could be limited in certain configurations.\\n- Recovery hooks are not recommended for towing, which may restrict towing options.\\n- Certain advanced driver-assistance systems (ADAS) features are only available on specific models or require additional packages.\\n- There are extra costs associated with certain color and interior choices, which could increase the overall price.', additional_kwargs={})]"
            ]
          },
          "metadata": {},
          "execution_count": 22
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Incorporating Semantic Caching\n",
        "We can also take advantage of frequently asked questions (live or prefetched) in order to improve response times."
      ],
      "metadata": {
        "id": "9qieviUEtpmn"
      },
      "id": "9qieviUEtpmn"
    },
    {
      "cell_type": "code",
      "source": [
        "from redisvl.extensions.llmcache import SemanticCache\n",
        "from redisvl.utils.vectorize import HFTextVectorizer\n",
        "\n",
        "emb = HFTextVectorizer(model=\"BAAI/bge-small-en-v1.5\")\n",
        "\n",
        "cache = SemanticCache(\n",
        "    name=\"chevy_cache\",\n",
        "    prefix=\"cache\",\n",
        "    distance_threshold=0.2,\n",
        "    ttl=60,\n",
        "    vectorizer=emb\n",
        ")"
      ],
      "metadata": {
        "id": "344-RjcW2GXL",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 84,
          "referenced_widgets": [
            "f3abe5efdb43424fb6232e93a14a2404",
            "20dbbf85c2b147eca3aeed7668f22c0f",
            "77108d3f7ad04a83a14636cfbff28161",
            "c5a3a291c5624f85af689f522a1cce97",
            "8d75f8a55c2c4a11aa0620b6c51b1d5f",
            "422540653bf644d786aabf55f2458356",
            "75c28f6d66be4a0dbc9a4df7e45d759f",
            "d930941b0e274836a6d2628dd91be5a1",
            "f5ee0a43ab1e45b58749a0365da15965",
            "619f8e4638d54e389653a82134141cf4",
            "dab0dfd8bdd74c0f9fd00e86bd83c549"
          ]
        },
        "outputId": "c51ead26-11d7-40d3-9bbe-5b0c11e915b8"
      },
      "id": "344-RjcW2GXL",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:31:30 sentence_transformers.SentenceTransformer INFO   Load pretrained SentenceTransformer: BAAI/bge-small-en-v1.5\n",
            "02:31:31 sentence_transformers.SentenceTransformer INFO   Use pytorch device_name: cpu\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Batches:   0%|          | 0/1 [00:00<?, ?it/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "f3abe5efdb43424fb6232e93a14a2404"
            }
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "def invoke_agent(prompt: str) -> str:\n",
        "    if cached_result := cache.check(prompt=prompt):\n",
        "        response = cached_result[0]['response']\n",
        "        return response\n",
        "    response = agent.chat(prompt)\n",
        "    # cache.store(prompt=prompt, response=response.response)\n",
        "    return response.response"
      ],
      "metadata": {
        "id": "QXGdA5ga2pod"
      },
      "id": "QXGdA5ga2pod",
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Now we can perform a simple test with our agent and semantic caching enabled."
      ],
      "metadata": {
        "id": "OlNK1VFc3m8q"
      },
      "id": "OlNK1VFc3m8q"
    },
    {
      "cell_type": "code",
      "source": [
        "invoke_agent(\"How many doors does the truck have?\")"
      ],
      "metadata": {
        "id": "kVVJlhfC3mPW",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 308,
          "referenced_widgets": [
            "ef9d5e170259480eb420f4a3123f99ad",
            "8d3a03f2ec3e4711b82c7d54ddb39c38",
            "26f913c7aca94affa17e4fce845ffe47",
            "6d116901ed6348a4ab911fda7bd600f4",
            "641f16f8646c4c398d10720fbcce8bb9",
            "3dc705f7ec974572af7abf3149ca9ffe",
            "5353d296915d4f0398f91c24d5d630c0",
            "edcb863c0961422aacecbb84b0d02f55",
            "c5834c4dc3294b448c642778123111e4",
            "9039857ead5d4a98989faafd09645a63",
            "f9e53b1301864009aabd7e1ad9ba3cd7",
            "9d928668dba84a929528326c37787e64",
            "9b6f03bf1bf948f2834e1a99a41e1091",
            "606b1232853d46688335c84fa746e8fc",
            "6b68c1aaed8240c3b30ea7a6a2d6ebaa",
            "90daabefd8ea4f7cb6d5eeaa4dd82055",
            "33c1b4c01fd64be18e70a56ce2b645d3",
            "ecb1947ef40a4522ad623417ce81821c",
            "dbefe9c6bb224534ba7d1e4c5ad1ca7d",
            "aeb79918b60e40bf85ddbb9c38bd0aec",
            "52608976b39d4fa48f2b8b717d34d341",
            "bc11e151215c41669d348776bcf7bac9"
          ]
        },
        "outputId": "92010259-ddd5-4665-a940-18c27ec3dae1"
      },
      "id": "kVVJlhfC3mPW",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Batches:   0%|          | 0/1 [00:00<?, ?it/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "ef9d5e170259480eb420f4a3123f99ad"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "02:31:42 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: The current language of the user is: English. I need to use a tool to help me answer the question.\n",
            "Action: vector_tool_2022_chevrolet_colorado_ebrochure\n",
            "Action Input: {'input': 'How many doors does the truck have?'}\n",
            "\u001b[0m02:31:42 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/embed \"HTTP/1.1 200 OK\"\n",
            "02:31:42 llama_index.vector_stores.redis.base INFO   Querying index chevy-colorado with filters *\n",
            "02:31:42 llama_index.vector_stores.redis.base INFO   Found 2 results for query with id ['pdf:chunk:3fda8d64-8947-45c8-a207-061eb4d6782d', 'pdf:chunk:444bbb71-04fc-4547-a069-0cadee0ff9b3']\n",
            "02:31:43 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;34mObservation: The truck has four doors.\n",
            "\u001b[0m02:31:44 httpx INFO   HTTP Request: POST https://api.cohere.ai/v1/chat \"HTTP/1.1 200 OK\"\n",
            "\u001b[1;3;38;5;200mThought: I can answer without using any more tools. I'll use the user's language to answer.\n",
            "Answer: The Chevy Colorado has four doors.\n",
            "\u001b[0m"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Batches:   0%|          | 0/1 [00:00<?, ?it/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "9d928668dba84a929528326c37787e64"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'The Chevy Colorado has four doors.'"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            }
          },
          "metadata": {},
          "execution_count": 35
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "invoke_agent(\"How many passenger doors are on the truck?\")"
      ],
      "metadata": {
        "id": "c37ICAFr5bQs",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 67,
          "referenced_widgets": [
            "668dd4f6eb34493583850fc5cfd4d097",
            "40ddc3e1e8c04a049f5d093a9eaf8e42",
            "e8e0a7d56b9a492c9eb1278956b73563",
            "73c305d51ce84e73a4173d295ce93d69",
            "81d16b7dad8f422a86117367a2d91502",
            "ea0a5eac062646128e50c1a03df1bf16",
            "d750515a4d8443a888ed039eb871becc",
            "5c93337f3d3647f8832402231a2408fa",
            "c5836378b2a8486b80c56f1556df7c98",
            "3af4eabed02e46cb8248b96ec2397cd9",
            "ada1176831a943748313e57f01093f89"
          ]
        },
        "outputId": "c894d7e8-5369-4861-a668-f0fd87df442e"
      },
      "id": "c37ICAFr5bQs",
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "Batches:   0%|          | 0/1 [00:00<?, ?it/s]"
            ],
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "668dd4f6eb34493583850fc5cfd4d097"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "'The Chevy Colorado has four doors.'"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "string"
            }
          },
          "metadata": {},
          "execution_count": 36
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Extending Semantic Caching\n",
        "\n",
        "\n",
        "There are a few options for working with semantic caching in a true production setting:\n",
        "1.   Extract FAQs from your Knowledge Base (pdfs...). Use an LLM to help! Or use human experts. Prefetch into the cache.\n",
        "2. Carefully, extract FAQs from conversation history. Prefetch in batches into the cache each day or week.\n",
        "3. Cache in realtime, which is tricky and requires some tuning. This should typically be done only at the USER level, not across the entire domain or application.\n",
        "\n",
        "**Stay tuned for more dedicated guides on semantic caching for RAG Agents and Redis.**\n",
        "\n",
        "\n"
      ],
      "metadata": {
        "id": "wvfTze4m3mhW"
      },
      "id": "wvfTze4m3mhW"
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "llama_index_v2",
      "language": "python",
      "name": "llama_index_v2"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3"
    },
    "colab": {
      "provenance": []
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "f3abe5efdb43424fb6232e93a14a2404": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_20dbbf85c2b147eca3aeed7668f22c0f",
              "IPY_MODEL_77108d3f7ad04a83a14636cfbff28161",
              "IPY_MODEL_c5a3a291c5624f85af689f522a1cce97"
            ],
            "layout": "IPY_MODEL_8d75f8a55c2c4a11aa0620b6c51b1d5f"
          }
        },
        "20dbbf85c2b147eca3aeed7668f22c0f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_422540653bf644d786aabf55f2458356",
            "placeholder": "​",
            "style": "IPY_MODEL_75c28f6d66be4a0dbc9a4df7e45d759f",
            "value": "Batches: 100%"
          }
        },
        "77108d3f7ad04a83a14636cfbff28161": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_d930941b0e274836a6d2628dd91be5a1",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_f5ee0a43ab1e45b58749a0365da15965",
            "value": 1
          }
        },
        "c5a3a291c5624f85af689f522a1cce97": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_619f8e4638d54e389653a82134141cf4",
            "placeholder": "​",
            "style": "IPY_MODEL_dab0dfd8bdd74c0f9fd00e86bd83c549",
            "value": " 1/1 [00:00&lt;00:00, 14.39it/s]"
          }
        },
        "8d75f8a55c2c4a11aa0620b6c51b1d5f": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "422540653bf644d786aabf55f2458356": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "75c28f6d66be4a0dbc9a4df7e45d759f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "d930941b0e274836a6d2628dd91be5a1": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f5ee0a43ab1e45b58749a0365da15965": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "619f8e4638d54e389653a82134141cf4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "dab0dfd8bdd74c0f9fd00e86bd83c549": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "ef9d5e170259480eb420f4a3123f99ad": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_8d3a03f2ec3e4711b82c7d54ddb39c38",
              "IPY_MODEL_26f913c7aca94affa17e4fce845ffe47",
              "IPY_MODEL_6d116901ed6348a4ab911fda7bd600f4"
            ],
            "layout": "IPY_MODEL_641f16f8646c4c398d10720fbcce8bb9"
          }
        },
        "8d3a03f2ec3e4711b82c7d54ddb39c38": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_3dc705f7ec974572af7abf3149ca9ffe",
            "placeholder": "​",
            "style": "IPY_MODEL_5353d296915d4f0398f91c24d5d630c0",
            "value": "Batches: 100%"
          }
        },
        "26f913c7aca94affa17e4fce845ffe47": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_edcb863c0961422aacecbb84b0d02f55",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_c5834c4dc3294b448c642778123111e4",
            "value": 1
          }
        },
        "6d116901ed6348a4ab911fda7bd600f4": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_9039857ead5d4a98989faafd09645a63",
            "placeholder": "​",
            "style": "IPY_MODEL_f9e53b1301864009aabd7e1ad9ba3cd7",
            "value": " 1/1 [00:00&lt;00:00,  2.44it/s]"
          }
        },
        "641f16f8646c4c398d10720fbcce8bb9": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "3dc705f7ec974572af7abf3149ca9ffe": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "5353d296915d4f0398f91c24d5d630c0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "edcb863c0961422aacecbb84b0d02f55": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c5834c4dc3294b448c642778123111e4": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "9039857ead5d4a98989faafd09645a63": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "f9e53b1301864009aabd7e1ad9ba3cd7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "9d928668dba84a929528326c37787e64": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_9b6f03bf1bf948f2834e1a99a41e1091",
              "IPY_MODEL_606b1232853d46688335c84fa746e8fc",
              "IPY_MODEL_6b68c1aaed8240c3b30ea7a6a2d6ebaa"
            ],
            "layout": "IPY_MODEL_90daabefd8ea4f7cb6d5eeaa4dd82055"
          }
        },
        "9b6f03bf1bf948f2834e1a99a41e1091": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_33c1b4c01fd64be18e70a56ce2b645d3",
            "placeholder": "​",
            "style": "IPY_MODEL_ecb1947ef40a4522ad623417ce81821c",
            "value": "Batches: 100%"
          }
        },
        "606b1232853d46688335c84fa746e8fc": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_dbefe9c6bb224534ba7d1e4c5ad1ca7d",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_aeb79918b60e40bf85ddbb9c38bd0aec",
            "value": 1
          }
        },
        "6b68c1aaed8240c3b30ea7a6a2d6ebaa": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_52608976b39d4fa48f2b8b717d34d341",
            "placeholder": "​",
            "style": "IPY_MODEL_bc11e151215c41669d348776bcf7bac9",
            "value": " 1/1 [00:00&lt;00:00, 12.80it/s]"
          }
        },
        "90daabefd8ea4f7cb6d5eeaa4dd82055": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "33c1b4c01fd64be18e70a56ce2b645d3": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "ecb1947ef40a4522ad623417ce81821c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "dbefe9c6bb224534ba7d1e4c5ad1ca7d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "aeb79918b60e40bf85ddbb9c38bd0aec": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "52608976b39d4fa48f2b8b717d34d341": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "bc11e151215c41669d348776bcf7bac9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "668dd4f6eb34493583850fc5cfd4d097": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HBoxModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HBoxView",
            "box_style": "",
            "children": [
              "IPY_MODEL_40ddc3e1e8c04a049f5d093a9eaf8e42",
              "IPY_MODEL_e8e0a7d56b9a492c9eb1278956b73563",
              "IPY_MODEL_73c305d51ce84e73a4173d295ce93d69"
            ],
            "layout": "IPY_MODEL_81d16b7dad8f422a86117367a2d91502"
          }
        },
        "40ddc3e1e8c04a049f5d093a9eaf8e42": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_ea0a5eac062646128e50c1a03df1bf16",
            "placeholder": "​",
            "style": "IPY_MODEL_d750515a4d8443a888ed039eb871becc",
            "value": "Batches: 100%"
          }
        },
        "e8e0a7d56b9a492c9eb1278956b73563": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "FloatProgressModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "ProgressView",
            "bar_style": "success",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_5c93337f3d3647f8832402231a2408fa",
            "max": 1,
            "min": 0,
            "orientation": "horizontal",
            "style": "IPY_MODEL_c5836378b2a8486b80c56f1556df7c98",
            "value": 1
          }
        },
        "73c305d51ce84e73a4173d295ce93d69": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_dom_classes": [],
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "HTMLModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/controls",
            "_view_module_version": "1.5.0",
            "_view_name": "HTMLView",
            "description": "",
            "description_tooltip": null,
            "layout": "IPY_MODEL_3af4eabed02e46cb8248b96ec2397cd9",
            "placeholder": "​",
            "style": "IPY_MODEL_ada1176831a943748313e57f01093f89",
            "value": " 1/1 [00:00&lt;00:00, 12.16it/s]"
          }
        },
        "81d16b7dad8f422a86117367a2d91502": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "ea0a5eac062646128e50c1a03df1bf16": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "d750515a4d8443a888ed039eb871becc": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        },
        "5c93337f3d3647f8832402231a2408fa": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "c5836378b2a8486b80c56f1556df7c98": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "ProgressStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "bar_color": null,
            "description_width": ""
          }
        },
        "3af4eabed02e46cb8248b96ec2397cd9": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_model_module": "@jupyter-widgets/base",
            "_model_module_version": "1.2.0",
            "_model_name": "LayoutModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "LayoutView",
            "align_content": null,
            "align_items": null,
            "align_self": null,
            "border": null,
            "bottom": null,
            "display": null,
            "flex": null,
            "flex_flow": null,
            "grid_area": null,
            "grid_auto_columns": null,
            "grid_auto_flow": null,
            "grid_auto_rows": null,
            "grid_column": null,
            "grid_gap": null,
            "grid_row": null,
            "grid_template_areas": null,
            "grid_template_columns": null,
            "grid_template_rows": null,
            "height": null,
            "justify_content": null,
            "justify_items": null,
            "left": null,
            "margin": null,
            "max_height": null,
            "max_width": null,
            "min_height": null,
            "min_width": null,
            "object_fit": null,
            "object_position": null,
            "order": null,
            "overflow": null,
            "overflow_x": null,
            "overflow_y": null,
            "padding": null,
            "right": null,
            "top": null,
            "visibility": null,
            "width": null
          }
        },
        "ada1176831a943748313e57f01093f89": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_model_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_model_name": "DescriptionStyleModel",
            "_view_count": null,
            "_view_module": "@jupyter-widgets/base",
            "_view_module_version": "1.2.0",
            "_view_name": "StyleView",
            "description_width": ""
          }
        }
      }
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}